<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script src="https://unpkg.com/vue@next"></script>
    <div id="app">
        <todo-item  v-model.capitalize="myText"></todo-item>
    </div>
    <script>
        const vueOpt = {
            data(){
                return {
                    myText: "kenny.bai",
                    otherText: "aaa"
                }
            }
        };

        const app = Vue.createApp(vueOpt);
        app.component('todo-item', {
            data(){
                return {

                }
            },

            props:{
                modelValue: String,
                modelModifiers:{
                    default:()=>({})
                },
                modifyName: String
            },
            methods:{
                inputChange(e){
                    let value = e.target.value;
                    console.log('value:', value);
                    if(this.modelModifiers.capitalize){
                        value = value.charAt(0).toUpperCase() + value.slice(1);
                    }
                    this.$emit('update:modelValue', value);
                }
            },

            template: `
                <div>
                    <input type="text" :value="modelValue" @input="inputChange">   
                </div>
            `
        });

        app.mount('#app');
    </script>
</body>
</html>